<html>
<head>
<#include "/common/common2.ftl"/>
</head>
<body>
	<div id="rrapp" v-cloak>
		<div v-show="showList">
			<div class="m-b-md"></div>
			<header class="panel-heading">
				<div class="doc-buttons">
					<a class="layui-btn layui-btn-danger" @click="addConfig">
						<i class="fa fa-sun-o"></i>
						&nbsp;云存储配置
					</a>
					<a class="layui-btn layui-btn-normal" id="upload">
						<i class="fa fa-plus"></i>
						&nbsp;上传文件
					</a>
					<a class="layui-btn layui-btn-normal" @click="del">
						<i class="fa fa-trash-o"></i>
						&nbsp;删除
					</a>
				</div>
			</header>
			<div class="table-responsive">
				<table class="layui-hide" id="osstable"></table>
			</div>
		</div>
		<div v-show="!showList" class="panel panel-default">
			<div class="panel-heading">{{title}}</div>
			<form class="layui-form layui-form-pane">
				<div class="layui-form-item">
					<label class="layui-form-label">存储类型</label>
					<label class="radio-inline">
						<input type="radio" name="type" v-model="config.type" value="1" />
						七牛
					</label>
					<label class="radio-inline">
						<input type="radio" name="type" v-model="config.type" value="2" />
						阿里云
					</label>
					<label class="radio-inline">
						<input type="radio" name="type" v-model="config.type" value="3" />
						腾讯云
					</label>
				</div>
				<div v-show="config.type == 1">
					<div class="layui-form-item">
						<label class="layui-form-label">&nbsp;</label>
						<p class="layui-input-static">
							<a href="http://www.renren.io/open/qiniu.html" target="_blank">免费申请(七牛)10GB储存空间</a>
						</p>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">域名</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qiniuDomain" placeholder="七牛绑定的域名" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">路径前缀</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qiniuPrefix" placeholder="不设置默认为空" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">AccessKey</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qiniuAccessKey" placeholder="七牛AccessKey" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">SecretKey</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qiniuSecretKey" placeholder="七牛SecretKey" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">空间名</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qiniuBucketName" placeholder="七牛存储空间名" />
						</div>
					</div>
				</div>
				<div v-show="config.type == 2">
					<div class="layui-form-item">
						<label class="layui-form-label">域名</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunDomain" placeholder="阿里云绑定的域名" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">路径前缀</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunPrefix" placeholder="不设置默认为空" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">EndPoint</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunEndPoint" placeholder="阿里云EndPoint" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">AccessKeyId</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunAccessKeyId" placeholder="阿里云AccessKeyId" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">AccessKeySecret</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunAccessKeySecret" placeholder="阿里云AccessKeySecret" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">BucketName</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.aliyunBucketName" placeholder="阿里云BucketName" />
						</div>
					</div>
				</div>
				<div v-show="config.type == 3">
					<div class="layui-form-item">
						<label class="layui-form-label">域名</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudDomain" placeholder="腾讯云绑定的域名" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">路径前缀</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudPrefix" placeholder="不设置默认为空" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">AppId</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudAppId" placeholder="腾讯云AppId" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">SecretId</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudSecretId" placeholder="腾讯云SecretId" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">SecretKey</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudSecretKey" placeholder="腾讯云SecretKey" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">BucketName</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudBucketName" placeholder="腾讯云BucketName" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">Bucket所属地区</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" v-model="config.qcloudRegion" placeholder="如：sh（可选值 ，华南：gz 华北：tj 华东：sh）" />
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<input type="button" class="layui-btn layui-btn-normal" @click="saveOrUpdate" value="确定" />
					&nbsp;&nbsp;
					<input type="button" class="layui-btn layui-btn-danger" @click="reload" value="返回" />
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="/js/system/oss/ajaxupload.js"></script>
	<script type="text/javascript" src="/js/system/oss/oss.js"></script>
</body>
<script type="text/javascript">
    new AjaxUpload('#upload', {
        action : '/sys/oss_do/upload.do',
        name : 'file',
        autoSubmit : true,
        responseType : "json",
        onSubmit : function(file, extension) {
            if (vm.config.type == null) {
                alert("云存储配置未配置");
                return false;
            }
            if (!(extension && /^(jpg|jpeg|png|gif)$/.test(extension.toLowerCase()))) {
                alert('只支持jpg、png、gif格式的图片！');
                return false;
            }
        },
        onComplete : function(file, r) {
            vm.reload();
            alert('图片url:' + r.url);
        }
    });
</script>
</html>